home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7140 < prev    next >
Encoding:
Text File  |  1996-08-05  |  851 b   |  49 lines

  1. Path: ubnsrv.unisource.ch!news
  2. From: Fabienne Guinnard <guinnard_f@scopus.ch>
  3. Newsgroups: comp.lang.c++
  4. Subject: Virtuals in constructor
  5. Date: Tue, 20 Feb 1996 22:17:38 +0100
  6. Organization: HelpDesign
  7. Message-ID: <312A3A72.688D@scopus.ch>
  8. NNTP-Posting-Host: user5.scopus.ch
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0GoldB1 (Win95; I)
  13.  
  14. Hi,
  15.  
  16. does anyone know why the following code doesn't work ?
  17.  
  18. Run-time error: pure virtual function called
  19.  
  20. class A
  21. {
  22.   public:
  23.     A(VOID) { Method(); }
  24.  
  25.     virtual VOID Method(VOID) = 0;
  26. };
  27.  
  28. class B : public A
  29. {
  30.   public:
  31.     B(VOID) {}
  32.  
  33.     VOID Method(VOID) { MessageBox(NULL, "", "", MB_OK); }
  34. };
  35.  
  36. int WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
  37. {
  38.     B b;
  39.  
  40.     return 0;
  41. }
  42.  
  43. Thanks
  44.  
  45.                 Laurent Guinnard
  46.                 guinnard@eig.unige.ch
  47.  
  48. be_well++;
  49.